<?php
/**
 * CI 数据库常量数据初始化
 *
 * @author Zeon <scplay@gmail.com>
 * @date 2018/6/29 9:05
 * @copyright PanxSoft Inc.
 */

namespace Tests\Utils;


use App\Models\Admin\CustomerAdmin;
use App\Models\Admin\PanxAdmin;
use App\Models\Admin\StoreAdmin;
use App\Models\Panx\ProductUrlType;
use Spatie\Permission\Models\Role;

class PanxData
{
    const DUSK_ENV_KEY = 'pkx.dusk.env';

    const DUSK_ENV_WECHAT = 'wechat';
    const DUSK_ENV_MOBILE = 'mobile';
    const DUSK_ENV_APP = 'app';
    const DUSK_ENV_ADMIN = 'admin';

    public static function initDefault(): void
    {
        self::initRoles();

        self::initProductUrlTypes();
    }

    private static function initRoles()
    {
        Role::insert([
            ['name' => PanxAdmin::SUPER_MAN , 'guard_name' => PanxAdmin::GUARD_NAME, 'const' => 'SUPER_MAN', ],
            ['name' => PanxAdmin::FINANCE, 'guard_name' => PanxAdmin::GUARD_NAME, 'const' => 'FINANCE', ],
            ['name' => CustomerAdmin::SUPER_MAN, 'guard_name' => CustomerAdmin::GUARD_NAME, 'const' => 'SUPER_MAN', ],
            ['name' => CustomerAdmin::FINANCE, 'guard_name' => CustomerAdmin::GUARD_NAME, 'const' => 'FINANCE', ],
            ['name' => StoreAdmin::SUPER_MAN, 'guard_name' => StoreAdmin::GUARD_NAME, 'const' => 'SUPER_MAN', ],
            ['name' => StoreAdmin::STAFF, 'guard_name' => StoreAdmin::GUARD_NAME, 'const' => 'STAFF', ],
            ['name' => StoreAdmin::FINANCE, 'guard_name' => StoreAdmin::GUARD_NAME, 'const' => 'FINANCE', ],
        ]);
    }

    private static function initProductUrlTypes()
    {
        ProductUrlType::insert([
            ['id' => ProductUrlType::ID_TAOBAO,'name' => '淘宝', 'const' => 'TAOBAO']
        ]);
    }
}